import java.util.*;

public class Test {

    public static void main(String[] args) {
        Set<String> set = new TreeSet<>();
        set.add("Hello");
        set.add("abcde");
//        set.add("abcde");
        set.add("world");
//        System.out.println(set);

        //迭代器
        Iterator<String> iterator = set.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }

//        for (String s:set) {
//            System.out.println(s);
//        }
    }

    public static void main2(String[] args) {
        Map<String,Integer> map = new TreeMap<>();
        map.put("hello",12);
        map.put("abcd",7);
        map.put("wolrd",24);
        System.out.println(map);

//        System.out.println(map.get("abcd"));
//        System.out.println(map.getOrDefault("abcd",8));
//        System.out.println(map.getOrDefault("abcdef",8));
//        Set<String> set = map.keySet();
//        System.out.println(set);
//        Collection<Integer> values = map.values();
//        System.out.println(values);

        Set<Map.Entry<String,Integer>> set = map.entrySet();
        for (Map.Entry<String,Integer>entry:set) {
            System.out.println("key : " + entry.getKey() + "; val : " + entry.getValue());
        }

    }

    public static void main1(String[] args) {
        int[] array = {4,2,1,6};
        BinarySearch binarySearch = new BinarySearch();
        for (int i = 0; i < array.length; i++) {
            binarySearch.insert(array[i]);
        }
        System.out.println(binarySearch.search(4));
        System.out.println(binarySearch.search(7));
    }
}
